import {action, observable, runInAction} from "mobx";
import {BaseResInterface, BaseResInterfaceWithData, sendGetRequest} from "../../../net";
import {defaultArr} from "../../../util";
import UserStoreInstance from "./index";
import {UserModelInterface} from "../../../net/instance/CommenModelInstance";


interface Team {
    member: UserModelInterface,
    userIntegral: number
}

export class TeamStore {
    @observable teamList: Team[] = defaultArr;

    @action.bound
    async getTeamMembers() {
        const {data} = await sendGetRequest<BaseResInterfaceWithData<Team[]>>("user/getTeamMembers", {
            userId: UserStoreInstance.user.id
        });
        runInAction(() => {
            this.teamList = data;
        })
    }

}

const TeamStoreInstance = new TeamStore();
export default TeamStoreInstance